package cn.edu.thu.tsqualitylite.common.util;

import cn.edu.thu.tsquality.core.common.table.Row;
import cn.edu.thu.tsquality.core.common.table.Table;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Created by wangyihan  on 2018/4/22 下午6:12.
 * E-mail address is yihanwang22@163.com.
 * Copyright © 2017 wangyihan. All Rights Reserved.
 *
 * @author wangyihan
 */
public class ServerTable {
  private List<Object> header;
  private List<List<Object>> dataList;

  public ServerTable(Table table) {
    this.header = Arrays.asList(table.getHeader().toArray());
    this.dataList = new ArrayList<>();
    dataList.addAll(table.getRows().stream().map(Row::toList).collect(Collectors.toList()));
  }

  public List<Object> getHeader() {
    return header;
  }

  public List<List<Object>> getDataList() {
    return dataList;
  }
}
